﻿using Storage.DbEntities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Storage.Repositories
{
	public class SetLogRep : Base.BaseRep<SetLogDbEntity>
	{
		public SetLogRep(SQLite.SQLiteAsyncConnection connection) : base(connection) { }

		public async Task<List<SetLogDbEntity>> GetByExerciseLogId(Guid exerciseLogId)
		{
            var sqlSelectCommand = String.Format("Select * From {0} where FK_ExerciseLogId = ?", TableName);
            return await _connection.QueryAsync<SetLogDbEntity>(sqlSelectCommand, exerciseLogId);
		}

        public async Task<List<SetLogDbEntity>> GetByExerciseLogIds(IEnumerable<Guid> exerciseLogIds)
        {
            var sqlSelectCommand = String.Format("Select * From {0} where FK_ExerciseLogId in ({1})", TableName, String.Join(",", exerciseLogIds.Select(x => String.Format("'{0}'", x))));
            var res = await _connection.QueryAsync<SetLogDbEntity>(sqlSelectCommand);
            return res;
        }
    }
}
